//
//  DBTabbarContentView.swift
//  DashBoard
//
//  Created by kf on 2017/6/27.
//  Copyright © 2017年 IngDan. All rights reserved.
//

import Foundation
import ESTabBarController_swift

class DBTabbarContentView: ESTabBarItemContentView {
    
    public var duration = 0.3
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    
        textColor = UIColor.gray
        iconColor = UIColor.gray
        
        highlightTextColor = UIColor.init(ts_red: 4, green: 189, blue: 231)
        highlightIconColor = UIColor.init(ts_red: 4, green: 189, blue: 231)
    }
    
    public required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func selectAnimation(animated: Bool, completion: (() -> ())?) {
        self.bounceAnimation()
        completion?()
    }
    
    override func reselectAnimation(animated: Bool, completion: (() -> ())?) {
        self.bounceAnimation()
        completion?()
    }
    
    func bounceAnimation() {
        let impliesAnimation = CAKeyframeAnimation(keyPath: "transform.scale")
        impliesAnimation.values = [1.0 ,1.4, 0.9, 1.15, 0.95, 1.02, 1.0]
        impliesAnimation.duration = duration * 2
        impliesAnimation.calculationMode = kCAAnimationCubic
        imageView.layer.add(impliesAnimation, forKey: nil)
    }
}
